package com.sky.mapper;

import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {
    /**
     *动态查询ShoppingCart
     */
    List<ShoppingCart> list(ShoppingCart shoppingCart);

    /**
     *通过id更新number
     */
    @Update("update shopping_cart set number=#{number} where id=#{id}")
    void updateNumberById(ShoppingCart shoppingCart);

    /**
     *商品加入购物车
     */
    void insert(ShoppingCart shoppingCart);

    /**
     * 清空购物车商品
     */
    @Delete("delete from shopping_cart where user_id=#{userId}")
    void deleteByUserId(Long userId);

    /**
     *通过id删除购物车商品
     */
    @Delete("delete from shopping_cart where id=#{id}")
    void deleteById(ShoppingCart shoppingCart);

    /**
     *批量插入
     */
    void insertBatch(List<ShoppingCart> shoppingCartList);
}
